package date_;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

/**
 * 输出今年的星期天都是几号
 */
public class DateTest06 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("输入年份");
        int year = input.nextInt();
        Calendar cal = Calendar.getInstance();
        cal.set(year, 0, 1);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd E");
        String format = simpleDateFormat.format(cal.getTime());
        System.out.println(format);
        System.out.println(cal.getTime());
        int count = 52;//一年52周
        while (count > 0) {
            if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                count--;
                String format1 = simpleDateFormat.format(cal.getTime());
                System.out.println(format1);
            }
            cal.set(Calendar.DATE, cal.get(Calendar.DATE) + 1);//如果不是周日就加一
        }
    }
}
